// 定时器
class TimerDelay {
    constructor(fn, t) {
        this.fn = fn
        this.t = t
        this.timer = setInterval(fn, t)
    }
    stop() {
        if (this.timer) {
            clearInterval(this.timer)
            this.timer = null
        }
        return this
    }
    start() {
        if (!this.timer) {
            this.stop()
            this.timer = setInterval(this.fn, this.t)
        }
        return this
    }
    reset(n) {
        this.t = n
        return this.stop().start()
    }
}

export default TimerDelay